package com.zzty.common;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class ReadFileNames {
    public List readfile(String filepath) throws FileNotFoundException, IOException {
        List<String> fileNames=new ArrayList<String>();
        try {
            File file = new File(filepath);
                String[] filelist = file.list();
                for (int i = 0; i < filelist.length; i++) {
                    File readfile = new File(filepath + "//" + filelist[i]);
                    if (!readfile.isDirectory()) {
                        fileNames.add(readfile.getName());
                    } else if (readfile.isDirectory()) {
                        readfile(filepath + "//" + filelist[i]);
                    }
                }
        } catch (FileNotFoundException e) {
            System.out.println("readfile()   Exception:" + e.getMessage());
        }
        return fileNames;
    }
}
